<!-- 市场空间 -->
<template>
	<card :cardHeight="cardHeight" noMore noborder cardTitle="市场空间"><Chart :optionData="option_column" style="height: 100%; padding-bottom: 10px"></Chart></card>
</template>

<script>
import StatisticsMixins from '../StatisticsMixins';
import { priceFormat } from '@/utils/base';
import { mortgageapi } from '@/api/index.js';
let hideStyle = {
	normal: {
		color: '#f7f8fa', //未完成的圆环的颜色
		label: {
			show: false
		},
		labelLine: {
			show: false
		}
	},
	emphasis: {
		show: false
	}
};
export default {
	name: 'alarmLevel',
	mixins: [StatisticsMixins],
	data() {
		return {
			option_column: {
				backgroundColor: '#fff',
				legend: {
					data: ['一级告警', '二级告警', '三级告警'],
					show: true,
					icon: 'circle',
					top: 'bottom',
					textStyle: {
						fontSize: 14
					}
				},
				series: [
					{
						name: 'Line 1',
						type: 'pie',
						clockWise: true, //顺时针
						radius: [180, 200],
						label: {
							normal: {
								show: false,
								position: 'inside'
							}
						},
						labelLine: {
							normal: {
								show: false
							}
						},

						hoverAnimation: false,
						data: [
							{
								value: 75,
								name: '一级告警',
								itemStyle: {
									normal: {
										color: '#FFAE78'
									}
								}
							},
							{
								value: 25,
								name: 'hide',
								itemStyle: hideStyle
							}
						]
					},
					{
						name: 'Line 2',
						type: 'pie',
						clockWise: true, //顺时针
						radius: [150, 170],
						label: {
							normal: {
								show: false,
								position: 'inside'
							}
						},
						labelLine: {
							normal: {
								show: false
							}
						},
						hoverAnimation: false,
						data: [
							{
								value: 65,
								name: '二级告警',
								itemStyle: {
									normal: {
										color: '#14C9C9'
									}
								}
							},
							{
								value: 35,
								name: 'hide',
								itemStyle: hideStyle
							}
						]
					},
					{
						name: 'Line 3',
						type: 'pie',
						clockWise: true, //顺时针
						radius: [120, 140],
						label: {
							normal: {
								show: false,
								position: 'inside'
							}
						},
						labelLine: {
							normal: {
								show: false
							}
						},
						hoverAnimation: false,
						data: [
							{
								value: 55,
								name: '三级告警',
								itemStyle: {
									normal: {
										color: '#48A2FE'
									}
								}
							},
							{
								value: 45,
								name: 'hide',
								itemStyle: hideStyle
							}
						]
					}
				]
			}
		};
	},
	methods: {
		getInfo() {
			this.$postAction(mortgageapi.echartsUrl.findMarketSpace + '?orgId=' + this.globalOrgId).then(da => {
				if (da.code == 1) {
					let list = da.data;
					let title = [],
						mortgageList = [],
						unMortgageList = [];
					for (var i = 0; i < list.length; i++) {
						title.push(list[i].farmName);
						mortgageList.push(list[i].pledgeCount);
						unMortgageList.push(list[i].unPledgeCount);
					}
					let option_column = { ...this.option_column };
					option_column.xAxis.data = [...title];
					option_column.series[0].data = mortgageList;
					option_column.series[1].data = unMortgageList;
					option_column.dataZoom[0].show = title.length > 10;
					if (option_column.dataZoom[0].show) {
						option_column.dataZoom[0].end = parseInt((10 * 100) / title.length);
						option_column.grid.bottom = '15%';
					} else {
						option_column.grid.bottom = 0;
						option_column.dataZoom[0].end = 100;
					}
					this.option_column = { ...option_column };
				}
			});
		}
	}
};
</script>
